﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Imaginecup.recycling.Object.Entity;
using Microsoft.Xna.Framework.Graphics;
using Imaginecup.Recycling.GameMan;

namespace Imaginecup.recycling.Object.Menu
{
    public class Menu : MenuComponent
    {
        List<MenuComponent> m_MenuList = new List<MenuComponent>();

        #region 생성자 오버로딩
        public Menu() {}
        public Menu(Vector2 position, Rectangle collisionRect)
        {
            m_Info = new ObjectInfo(position, collisionRect);
            m_Texture = ResourceManager.GetInstance().GetContent("inventory");
        }
        public Menu(Texture2D texture, Vector2 position, Rectangle collisionRect)
        {
            m_Info = new ObjectInfo(position, collisionRect);
            m_Texture = texture;
        }
        #endregion

        public override void Add(MenuComponent menuComponent)
        {
            this.m_MenuList.Add(menuComponent);
        }

        public override void Remove(MenuComponent menuComponent)
        {
            if(m_MenuList.Contains(menuComponent))
                this.m_MenuList.Remove(menuComponent);
        }
        public override void Clear()
        {
            this.m_MenuList.Clear();
        }

        public override MenuComponent GetChild(int i)
        {
            return m_MenuList.ElementAt(i);
        }

        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            if(m_Texture != null)
            {
                base.Draw(spriteBatch, gameTime);
            }
            foreach (MenuComponent component in m_MenuList)
            {
                component.Draw(spriteBatch, gameTime);
            }
        }
        public override bool IsItem()
        {
            if (m_MenuList.Count != 0)
                return true;
            else 
                return false;
        }
    }
}
